<template>
  <div id="app">
    <mytitle />
    <router-view></router-view>

    <el-dialog title="登录" :visible.sync="showD" width="50%" center>
      <!-- login  -->
      <login ref="login"></login>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" :testConl="testConl" @click="testDB"
          >测试链接</el-button
        >
        <el-button
          type="primary"
          size="mini"
          :content="content"
          @click="contentDB"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
const { ipcRenderer } = require('electron')
import mytitle from "./components/myTitle/title";
import Login from "./components/sysComponets/login.vue";
import mysql from "@/utils/data/mysql.js";
import sys_data from './service/sys_data'

export default {
  name: "mydemo",
  components: {
    mytitle,
    Login,
  },
  data() {
    return {
      showD: false,
      content: false,
      testConl: false,
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      mysql.test((flag) => {
        if (!flag) {
          this.$message({
            message: "未获取到配置信息，请先登录系统！",
            type: "warning",
          });
          setTimeout(() => {
            this.showD = true;
          }, 1000);
        } else {
          this.$notify({
            title: "数据库连接成功,正在初始化数据！",
            message:  mysql.config.host,
            position: "bottom-right",
          });
          sys_data.getDataTable();
          console.log(this.$db.read().get('table').value());
        }
      });
    },
    contentDB() {
      this.$refs.login.onSubmit();
      this.content = true;
    },
    testDB() {
      this.$refs.login.testDB();
      this.testConl = true;
    },
  },
};
</script>

<style>
#app {
  height: calc(100vh - 28px);
}
/* CSS */
html,
body {
  height: calc(100vh - 28px);
  margin: 0;
  padding: 0;
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}
</style>
